package router

import (
	"gateway-server/internal/controller"
	"gateway-server/internal/schema"
	"gateway-server/pkg/beego"
)

type GatewayRouter struct {
	ModelController controller.ModelController
}

func NewGatewayRouter() *GatewayRouter {
	return &GatewayRouter{
		ModelController: controller.NewModelController(),
	}
}
func (gr *GatewayRouter) route(pattern string, mappingMethods string) {
	beego.Route(pattern, &gr.ModelController, mappingMethods)
}

type gatewayRoute struct {
	Path            string
	Method          string
	HandlerFuncName string
}

var gatewayRoutes = map[string]gatewayRoute{
	schema.UniformedChatCompletionsHandlerFuncName: {
		Path:            schema.UniformedChatCompletionsPath,
		Method:          schema.MethodPost,
		HandlerFuncName: schema.UniformedChatCompletionsHandlerFuncName,
	},
}

func (gr *GatewayRouter) Route() {
	for _, r := range gatewayRoutes {
		mappingMethods := r.Method + ":" + r.HandlerFuncName
		gr.route(r.Path, mappingMethods)
	}
}
